package com.jbp.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jbp.dao.UnionDao;
import com.jbp.model.Unioner;
import com.jbp.service.UnionService;
import org.springframework.stereotype.Service;
import com.jbp.utils.PageUtils;
import com.jbp.utils.Query;
import java.util.Map;

/**
 * 工会(Union)表服务实现类
 * @author cc
 * @since 2021-08-05 20:48:19
 */
@Service
public class UnionServiceImpl extends ServiceImpl<UnionDao, Unioner> implements UnionService {
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<Unioner> queryWrapper = new QueryWrapper<>();
        if (params.get("id") != null){
            queryWrapper.like("id",params.get("id"));
        }
        IPage<Unioner> page = this.page(
                new Query<Unioner>().getPage(params),
                queryWrapper
        );

        return new PageUtils(page);
    }

    @Override
    public Unioner getByUuid(Integer unionUuid) {
        QueryWrapper<Unioner> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("uuid", unionUuid);
        return getOne(queryWrapper);
    }
}